
package com.base.app_core.util;

import android.app.Activity;
import android.support.annotation.NonNull;

import com.afollestad.materialdialogs.DialogAction;
import com.afollestad.materialdialogs.MaterialDialog;

/**
 * 对话框的统一类 Created by Administrator on 2016/5/6.
 */
public final class MaterialDialogHelper {

    public static void showSingleText(Activity context, String Content,
                                      String cancelTex, String positiveText,
                                      final onItemClickLisener dialogBtnClick) {
        if (context == null || context.isFinishing() || dialogBtnClick == null) {
            return;
        }

        MaterialDialog.Builder builder = new MaterialDialog.Builder(context);
        builder.content(Content);
        builder.onPositive(new MaterialDialog.SingleButtonCallback() {
            @Override
            public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                dialogBtnClick.onPosiClick(dialog, which);
            }
        });
        builder.negativeText(cancelTex);
        builder.onNegative(new MaterialDialog.SingleButtonCallback() {
            @Override
            public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                dialogBtnClick.onNatiClick(dialog, which);
            }
        });
        builder.positiveText(positiveText);
        MaterialDialog build = builder.build();
        build.show();
    }


    public interface onItemClickLisener {
        void onPosiClick(MaterialDialog dialog, DialogAction which);

        void onNatiClick(MaterialDialog dialog, DialogAction which);
    }
}
